var app = angular.module('conversionTool', [ 'ui.bootstrap' ]);

app.controller('csvTypeAdaptorCtrl', [
		'$scope',
		'$http',
		function($scope, $http) {

			$scope.isEdit = false;

			$scope.currentDataAdaptor = new Object();

			$scope.csvDataType = new Object();

			$scope.isDefault = true;

			$scope.defaultClick = function() {

				if ($scope.isDefault) {
					$scope.lineSeparator = "";
					$scope.columnSepatator = "";
				}
			}

			// upload the document and data to server
			$scope.upload = function() {

				if (document.getElementById("csvTemplateFile").value != ""
						&& document.getElementById("csvTemplateFile").value != undefined) {
					return true;
				} else if (isDefault == false && ($scope.lineSeparator.length == 0 || $scope.columnSepatator == 0)) {
					$scope.msg = "please set collect Sepatator";
					return false;
				} else {
					$scope.msg = "please set a file to upload";
					return false;
				}
			}

			$scope.edit = function() {
				$scope.isEdit = true;
			}

			$scope.filter = function() {
				window.location="/dataAdaptor/filter?dataTemplateId="+$scope.currentDataAdaptor.id;
			}

			$scope.formula = function() {
				window.location="/dataAdaptor/formula?dataTemplateId="+$scope.currentDataAdaptor.id;
			}
			
			

		} ]);